/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vdoc.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.util.PortalUtil;

import com.vportal.portlet.vdoc.model.vdocField;
import com.vportal.portlet.vdoc.model.vdocFieldModel;
import com.vportal.portlet.vdoc.model.vdocFieldSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the vdocField service. Represents a row in the &quot;vdocField&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vdoc.model.vdocFieldModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link vdocFieldImpl}.
 * </p>
 *
 * @author MrEn
 * @see vdocFieldImpl
 * @see com.vportal.portlet.vdoc.model.vdocField
 * @see com.vportal.portlet.vdoc.model.vdocFieldModel
 * @generated
 */
@JSON(strict = true)
public class vdocFieldModelImpl extends BaseModelImpl<vdocField>
	implements vdocFieldModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a vdoc field model instance should use the {@link com.vportal.portlet.vdoc.model.vdocField} interface instead.
	 */
	public static final String TABLE_NAME = "vdocField";
	public static final Object[][] TABLE_COLUMNS = {
			{ "fieldId", Types.VARCHAR },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "createdDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "createdByUser", Types.BIGINT },
			{ "modifiedByUser", Types.BIGINT },
			{ "parentId", Types.VARCHAR },
			{ "name", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "language", Types.VARCHAR },
			{ "statusField", Types.BOOLEAN },
			{ "position", Types.INTEGER },
			{ "listparent", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table vdocField (fieldId VARCHAR(75) not null primary key,groupId LONG,companyId LONG,userId LONG,createdDate DATE null,modifiedDate DATE null,createdByUser LONG,modifiedByUser LONG,parentId VARCHAR(500) null,name VARCHAR(500) null,description VARCHAR(1000) null,language VARCHAR(500) null,statusField BOOLEAN,position INTEGER,listparent VARCHAR(1000) null)";
	public static final String TABLE_SQL_DROP = "drop table vdocField";
	public static final String ORDER_BY_JPQL = " ORDER BY vdocField.position ASC";
	public static final String ORDER_BY_SQL = " ORDER BY vdocField.position ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vdoc.model.vdocField"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vdoc.model.vdocField"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vdoc.model.vdocField"),
			true);
	public static long GROUPID_COLUMN_BITMASK = 1L;
	public static long LANGUAGE_COLUMN_BITMASK = 2L;
	public static long PARENTID_COLUMN_BITMASK = 4L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static vdocField toModel(vdocFieldSoap soapModel) {
		vdocField model = new vdocFieldImpl();

		model.setFieldId(soapModel.getFieldId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setUserId(soapModel.getUserId());
		model.setCreatedDate(soapModel.getCreatedDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setCreatedByUser(soapModel.getCreatedByUser());
		model.setModifiedByUser(soapModel.getModifiedByUser());
		model.setParentId(soapModel.getParentId());
		model.setName(soapModel.getName());
		model.setDescription(soapModel.getDescription());
		model.setLanguage(soapModel.getLanguage());
		model.setStatusField(soapModel.getStatusField());
		model.setPosition(soapModel.getPosition());
		model.setListparent(soapModel.getListparent());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<vdocField> toModels(vdocFieldSoap[] soapModels) {
		List<vdocField> models = new ArrayList<vdocField>(soapModels.length);

		for (vdocFieldSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vdoc.model.vdocField"));

	public vdocFieldModelImpl() {
	}

	public String getPrimaryKey() {
		return _fieldId;
	}

	public void setPrimaryKey(String primaryKey) {
		setFieldId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _fieldId;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return vdocField.class;
	}

	public String getModelClassName() {
		return vdocField.class.getName();
	}

	@JSON
	public String getFieldId() {
		if (_fieldId == null) {
			return StringPool.BLANK;
		}
		else {
			return _fieldId;
		}
	}

	public void setFieldId(String fieldId) {
		_fieldId = fieldId;
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	@JSON
	public Date getCreatedDate() {
		return _createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		_createdDate = createdDate;
	}

	@JSON
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	@JSON
	public long getCreatedByUser() {
		return _createdByUser;
	}

	public void setCreatedByUser(long createdByUser) {
		_createdByUser = createdByUser;
	}

	@JSON
	public long getModifiedByUser() {
		return _modifiedByUser;
	}

	public void setModifiedByUser(long modifiedByUser) {
		_modifiedByUser = modifiedByUser;
	}

	@JSON
	public String getParentId() {
		if (_parentId == null) {
			return StringPool.BLANK;
		}
		else {
			return _parentId;
		}
	}

	public void setParentId(String parentId) {
		_columnBitmask |= PARENTID_COLUMN_BITMASK;

		if (_originalParentId == null) {
			_originalParentId = _parentId;
		}

		_parentId = parentId;
	}

	public String getOriginalParentId() {
		return GetterUtil.getString(_originalParentId);
	}

	@JSON
	public String getName() {
		if (_name == null) {
			return StringPool.BLANK;
		}
		else {
			return _name;
		}
	}

	public void setName(String name) {
		_name = name;
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public String getLanguage() {
		if (_language == null) {
			return StringPool.BLANK;
		}
		else {
			return _language;
		}
	}

	public void setLanguage(String language) {
		_columnBitmask |= LANGUAGE_COLUMN_BITMASK;

		if (_originalLanguage == null) {
			_originalLanguage = _language;
		}

		_language = language;
	}

	public String getOriginalLanguage() {
		return GetterUtil.getString(_originalLanguage);
	}

	@JSON
	public boolean getStatusField() {
		return _statusField;
	}

	public boolean isStatusField() {
		return _statusField;
	}

	public void setStatusField(boolean statusField) {
		_statusField = statusField;
	}

	@JSON
	public int getPosition() {
		return _position;
	}

	public void setPosition(int position) {
		_columnBitmask = -1L;

		_position = position;
	}

	@JSON
	public String getListparent() {
		if (_listparent == null) {
			return StringPool.BLANK;
		}
		else {
			return _listparent;
		}
	}

	public void setListparent(String listparent) {
		_listparent = listparent;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public vdocField toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (vdocField)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		vdocFieldImpl vdocFieldImpl = new vdocFieldImpl();

		vdocFieldImpl.setFieldId(getFieldId());
		vdocFieldImpl.setGroupId(getGroupId());
		vdocFieldImpl.setCompanyId(getCompanyId());
		vdocFieldImpl.setUserId(getUserId());
		vdocFieldImpl.setCreatedDate(getCreatedDate());
		vdocFieldImpl.setModifiedDate(getModifiedDate());
		vdocFieldImpl.setCreatedByUser(getCreatedByUser());
		vdocFieldImpl.setModifiedByUser(getModifiedByUser());
		vdocFieldImpl.setParentId(getParentId());
		vdocFieldImpl.setName(getName());
		vdocFieldImpl.setDescription(getDescription());
		vdocFieldImpl.setLanguage(getLanguage());
		vdocFieldImpl.setStatusField(getStatusField());
		vdocFieldImpl.setPosition(getPosition());
		vdocFieldImpl.setListparent(getListparent());

		vdocFieldImpl.resetOriginalValues();

		return vdocFieldImpl;
	}

	public int compareTo(vdocField vdocField) {
		int value = 0;

		if (getPosition() < vdocField.getPosition()) {
			value = -1;
		}
		else if (getPosition() > vdocField.getPosition()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		vdocField vdocField = null;

		try {
			vdocField = (vdocField)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		String primaryKey = vdocField.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
		vdocFieldModelImpl vdocFieldModelImpl = this;

		vdocFieldModelImpl._originalGroupId = vdocFieldModelImpl._groupId;

		vdocFieldModelImpl._setOriginalGroupId = false;

		vdocFieldModelImpl._originalParentId = vdocFieldModelImpl._parentId;

		vdocFieldModelImpl._originalLanguage = vdocFieldModelImpl._language;

		vdocFieldModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<vdocField> toCacheModel() {
		vdocFieldCacheModel vdocFieldCacheModel = new vdocFieldCacheModel();

		vdocFieldCacheModel.fieldId = getFieldId();

		String fieldId = vdocFieldCacheModel.fieldId;

		if ((fieldId != null) && (fieldId.length() == 0)) {
			vdocFieldCacheModel.fieldId = null;
		}

		vdocFieldCacheModel.groupId = getGroupId();

		vdocFieldCacheModel.companyId = getCompanyId();

		vdocFieldCacheModel.userId = getUserId();

		Date createdDate = getCreatedDate();

		if (createdDate != null) {
			vdocFieldCacheModel.createdDate = createdDate.getTime();
		}
		else {
			vdocFieldCacheModel.createdDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			vdocFieldCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			vdocFieldCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		vdocFieldCacheModel.createdByUser = getCreatedByUser();

		vdocFieldCacheModel.modifiedByUser = getModifiedByUser();

		vdocFieldCacheModel.parentId = getParentId();

		String parentId = vdocFieldCacheModel.parentId;

		if ((parentId != null) && (parentId.length() == 0)) {
			vdocFieldCacheModel.parentId = null;
		}

		vdocFieldCacheModel.name = getName();

		String name = vdocFieldCacheModel.name;

		if ((name != null) && (name.length() == 0)) {
			vdocFieldCacheModel.name = null;
		}

		vdocFieldCacheModel.description = getDescription();

		String description = vdocFieldCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			vdocFieldCacheModel.description = null;
		}

		vdocFieldCacheModel.language = getLanguage();

		String language = vdocFieldCacheModel.language;

		if ((language != null) && (language.length() == 0)) {
			vdocFieldCacheModel.language = null;
		}

		vdocFieldCacheModel.statusField = getStatusField();

		vdocFieldCacheModel.position = getPosition();

		vdocFieldCacheModel.listparent = getListparent();

		String listparent = vdocFieldCacheModel.listparent;

		if ((listparent != null) && (listparent.length() == 0)) {
			vdocFieldCacheModel.listparent = null;
		}

		return vdocFieldCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(31);

		sb.append("{fieldId=");
		sb.append(getFieldId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", createdDate=");
		sb.append(getCreatedDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", createdByUser=");
		sb.append(getCreatedByUser());
		sb.append(", modifiedByUser=");
		sb.append(getModifiedByUser());
		sb.append(", parentId=");
		sb.append(getParentId());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", language=");
		sb.append(getLanguage());
		sb.append(", statusField=");
		sb.append(getStatusField());
		sb.append(", position=");
		sb.append(getPosition());
		sb.append(", listparent=");
		sb.append(getListparent());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(49);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vdoc.model.vdocField");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>fieldId</column-name><column-value><![CDATA[");
		sb.append(getFieldId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdDate</column-name><column-value><![CDATA[");
		sb.append(getCreatedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdByUser</column-name><column-value><![CDATA[");
		sb.append(getCreatedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedByUser</column-name><column-value><![CDATA[");
		sb.append(getModifiedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>parentId</column-name><column-value><![CDATA[");
		sb.append(getParentId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>language</column-name><column-value><![CDATA[");
		sb.append(getLanguage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>statusField</column-name><column-value><![CDATA[");
		sb.append(getStatusField());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>position</column-name><column-value><![CDATA[");
		sb.append(getPosition());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>listparent</column-name><column-value><![CDATA[");
		sb.append(getListparent());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = vdocField.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			vdocField.class
		};
	private String _fieldId;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private long _userId;
	private String _userUuid;
	private Date _createdDate;
	private Date _modifiedDate;
	private long _createdByUser;
	private long _modifiedByUser;
	private String _parentId;
	private String _originalParentId;
	private String _name;
	private String _description;
	private String _language;
	private String _originalLanguage;
	private boolean _statusField;
	private int _position;
	private String _listparent;
	private long _columnBitmask;
	private vdocField _escapedModelProxy;
}